<!DOCTYPE html>
<html>
<head>
    <title>试剂修改</title>
    {% include 'system/common/header.html' %}</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label">ID</label>
                    <div class="layui-input-block">
                        <input type="text" value="{{ reagent.id }}" name="id" lay-verify="title"
                               autocomplete="off" placeholder="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">试剂名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="reagentName" lay-verify="title" autocomplete="off"
                               placeholder="请输入设备名称"
                               class="layui-input" value="{{ reagent.reagentName }}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        试剂浓度
                    </label>
                    <div class="layui-input-block">
                        <div class="layui-input-group">
                            <input type="text" name="thickness" lay-verify="title" autocomplete="off"
                                   placeholder="请输入试剂浓度"
                                   class="layui-input" value="{{ reagent.thickness }}">
                            <div class="layui-input-suffix">
                                mol/L
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        可用容量
                    </label>
                    <div class="layui-input-block">
                        <div class="layui-input-group">
                            <input type="text" name="volume" lay-verify="title" autocomplete="off" placeholder="请输入可用容量"
                                   class="layui-input" value="{{ reagent.volume }}">
                            <div class="layui-input-suffix">
                                L
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">制造商</label>
                    <div class="layui-input-block">
                        <input type="text" name="producer" lay-verify="title" autocomplete="off"
                               placeholder="请输入制造商"
                               class="layui-input" value="{{ reagent.producer }}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">存储条件</label>
                    <div class="layui-input-block">
                        <input type="text" name="storage_condition" lay-verify="title" autocomplete="off"
                               placeholder="请输入存储条件"
                               class="layui-input" value="{{ reagent.storage_condition }}">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">试剂描述</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入试剂用途" name="description" class="layui-textarea">{{ reagent.description }}</textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="reagent-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
{% include 'system/common/footer.html' %}
<script>
    layui.use(['form', 'jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let laydate = layui.laydate;

        laydate.render({
            elem: '#purchase_date'
        });

        form.on('submit(reagent-save)', function (data) {
            {#console.log(data.field)#}
            $.ajax({
                url: '/system/reagent/update',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'put',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
                            parent.layui.table.reload('reagent-table')
                        })
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000})
                    }
                }
            })
            return false
        })
    })
</script>
</body>
</html>